package ru.home.documentmanager.dao.impl;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import ru.home.documentmanager.dao.UserDataDAO;
import ru.home.documentmanager.model.User;
import ru.home.documentmanager.model.UserData;

@Repository("userDataDAO")
public class UserDataDAOImpl extends AbstractDAO<UserData> implements
        UserDataDAO {

    public UserDataDAOImpl() {
        super(UserData.class);
    }

    @Override
    public UserData findByUser(User user) {
        return (UserData) getSession().createCriteria(UserData.class)
                .add(Restrictions.eq("user", user)).uniqueResult();
    }

}
